package com.bamboo.toolbox.hotdeploy.action;

import com.bamboo.toolbox.hotdeploy.dialog.DeployDialog;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.CommonDataKeys;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiFile;
import org.jetbrains.annotations.NotNull;


/**
 * @author: luzhiqing
 * @date: 2022-10-19
 **/
public class DeployAction extends AnAction {
    @Override
    public void actionPerformed(@NotNull AnActionEvent event) {

        Project project = event.getProject();

        PsiFile psiFile = event.getData(CommonDataKeys.PSI_FILE);
        if (null == psiFile) {
            return;
        }
        String path = psiFile.getVirtualFile().getPath();
        DeployDialog deployDialog = new DeployDialog(project);
        deployDialog.setTitle("HotDeploy");
        deployDialog.getFile().setText(path);
        deployDialog.init();
        deployDialog.setModal(true);
        deployDialog.show();
    }
}
